export default class ExtractData {
    private static instance: ExtractData = new ExtractData();
    /**
     * 提取数据
     */
    public static get Default(): ExtractData {
        return this.instance;
    }

    public Extract = (name: any) => {
        
        let xhr = new XMLHttpRequest()
        // this.isFilePathValid( `./Config/${name}.txt`)
        xhr.open("GET", `/Config/${name}.txt`, false); // public文件夹下的绝对路径
        xhr.overrideMimeType("text/html;charset=utf-8")
        xhr.send(null)
        // console.log(xhr);

        // xhr.responseText.split('\n').forEach(item => {
        //     console.log(JSON.parse(item), '回调');
        // });
        // console.log();
        
        return xhr.responseText.split('\n')

        // name为文件所在位置
        // let name = `/Config/${val}.txt`
        // let xhr = new XMLHttpRequest();
        // const okStatus = document.location.protocol === "file:" ? 0 : 200;
        // xhr.open("GET", name, false);
        // xhr.overrideMimeType("text/html;charset=utf-8"); //默认为utf-8
        // xhr.send(null);
        // console.log(xhr);
        
        // return xhr.status === okStatus ? xhr.responseText : null;

    }
}